package vcp.client.GUI.mvc.model;

import vcp.client.request.CustomerCheckoutRequest;
import vcp.client.utility.Common.UserNotification;
import vcp.enums.PopUpMessageType;
import vcp.enums.Screen;
import vcp.enums.SiteEnum;
/**
 * 
 * @author VCP team
 *<p>
 *check out model
 *</>
 *@see UIAbstractModel
 */
public class UICheckoutModel extends UIAbstractModel
{
	/** site number **/
	private SiteEnum site;

	public SiteEnum getSite ()
	{
		return this.site;
	}

	public void setSite ( SiteEnum site )
	{
		this.site = site;
	}

	public UICheckoutModel ( UIRootModel model )
	{
		super(model);
	}
	/**
	 * check if the car id are correct
	 * @param carID
	 */
	public void verifyCheckOutInfo ( int carID )
	{
		CustomerCheckoutRequest request = new CustomerCheckoutRequest(carID, this.site);
		this.sendRequest(request, true);
	}

	/****************************************************************************************************************************
	 *** Observer methods ***
	 ****************************************************************************************************************************/
	@Override
	public void update ( Object data )
	{
		if ( data instanceof Boolean )
		{
			this.controllerDelegate.showPopUpMessage(UserNotification.CHECK_IN_WAS_REGISTERED, PopUpMessageType.INFORMATION);
			this.controllerDelegate.loadMVC(Screen.ONSITE);
		}
		else if ( data instanceof String )
		{
			this.controllerDelegate.showPopUpMessage((String) data, PopUpMessageType.INFORMATION);
			this.controllerDelegate.loadMVC(Screen.ONSITE);
		}
	}
}
